home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / PInterfaces / OSA.p < prev    next >
Encoding:
Text File  |  1998-08-17  |  53.4 KB  |  1,467 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        OSA.p
  3.  
  4.      Contains:    AppleScript Client Interfaces.
  5.  
  6.      Version:    Technology:    AppleScript 1.1
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1992-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. }
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT OSA;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __OSA__}
  27. {$SETC __OSA__ := 1}
  28.  
  29. {$I+}
  30. {$SETC OSAIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33. {$IFC UNDEFINED __ERRORS__}
  34. {$I Errors.p}
  35. {$ENDC}
  36. {$IFC UNDEFINED __APPLEEVENTS__}
  37. {$I AppleEvents.p}
  38. {$ENDC}
  39. {$IFC UNDEFINED __AEOBJECTS__}
  40. {$I AEObjects.p}
  41. {$ENDC}
  42. {$IFC UNDEFINED __COMPONENTS__}
  43. {$I Components.p}
  44. {$ENDC}
  45.  
  46.  
  47. {$PUSH}
  48. {$ALIGN MAC68K}
  49. {$LibExport+}
  50.  
  51. {*************************************************************************
  52.     Types and Constants
  53. *************************************************************************}
  54.  
  55. {    The componenent manager type code for components that
  56.         support the OSA interface defined here. }
  57. { 0x6f736120 }
  58.  
  59. CONST
  60.     kOSAComponentType            = 'osa ';
  61.  
  62. { 0x73637074 }
  63.     kOSAGenericScriptingComponentSubtype = 'scpt';
  64.  
  65. {    Type of script document files.    }
  66. { 0x6f736173 }
  67.     kOSAFileType                = 'osas';
  68.  
  69. {
  70.         Suite and event code of the RecordedText event. 
  71.         (See OSAStartRecording, below.)
  72.     }
  73. { 0x61736372 }
  74.     kOSASuite                    = 'ascr';
  75.  
  76. { 0x72656364 }
  77.     kOSARecordedText            = 'recd';
  78.  
  79. { Selector returns boolean }
  80. { 0x6d6f6469 }
  81.     kOSAScriptIsModified        = 'modi';
  82.  
  83. { Selector returns boolean }
  84. { 0x63736372 }
  85.     kOSAScriptIsTypeCompiledScript = 'cscr';
  86.  
  87. { Selector returns boolean }
  88. { 0x76616c75 }
  89.     kOSAScriptIsTypeScriptValue    = 'valu';
  90.  
  91. { Selector returns boolean }
  92. { 0x636e7478 }
  93.     kOSAScriptIsTypeScriptContext = 'cntx';
  94.  
  95. { Selector returns a DescType which may be passed to OSACoerceToDesc }
  96. { 0x62657374 }
  97.     kOSAScriptBestType            = 'best';
  98.  
  99. {
  100.         This selector is used to determine whether a script has source 
  101.         associated with it that when given to OSAGetSource, the call will not
  102.         fail.  The selector returns a boolean.
  103.     }
  104. { 0x67737263 }
  105.     kOSACanGetSource            = 'gsrc';
  106.  
  107.  
  108.     typeOSADialectInfo            = 'difo';                        {   0x6469666f    }
  109.     keyOSADialectName            = 'dnam';                        {   0x646e616d    }
  110.     keyOSADialectCode            = 'dcod';                        {   0x64636f64    }
  111.     keyOSADialectLangCode        = 'dlcd';                        {   0x646c6364    }
  112.     keyOSADialectScriptCode        = 'dscd';                        {   0x64736364    }
  113.  
  114.  
  115. TYPE
  116.     OSAError                            = ComponentResult;
  117. { Under the Open Scripting Architecture all error results are longs }
  118.     OSAID                                = UInt32;
  119. {
  120.         OSAIDs allow transparent manipulation of scripts associated with
  121.          various scripting systems.
  122.     }
  123.  
  124. CONST
  125.     kOSANullScript                = 0;
  126.  
  127. { No -script constant. }
  128.     kOSANullMode                = 0;                            {  sounds better  }
  129.     kOSAModeNull                = 0;                            {  tastes consistent  }
  130.  
  131. {
  132.         Some routines take flags that control their execution.  This constant
  133.         declares default mode settings are used.
  134.     }
  135.  
  136. TYPE
  137. {$IFC TYPED_FUNCTION_POINTERS}
  138.     OSACreateAppleEventProcPtr = FUNCTION(theAEEventClass: AEEventClass; theAEEventID: AEEventID; {CONST}VAR target: AEAddressDesc; returnID: INTEGER; transactionID: LONGINT; VAR result: AppleEvent; refCon: LONGINT): OSErr;
  139. {$ELSEC}
  140.     OSACreateAppleEventProcPtr = ProcPtr;
  141. {$ENDC}
  142.  
  143. {$IFC TYPED_FUNCTION_POINTERS}
  144.     OSASendProcPtr = FUNCTION({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: LONGINT; idleProc: AEIdleUPP; filterProc: AEFilterUPP; refCon: LONGINT): OSErr;
  145. {$ELSEC}
  146.     OSASendProcPtr = ProcPtr;
  147. {$ENDC}
  148.  
  149.     OSACreateAppleEventUPP = UniversalProcPtr;
  150.     OSASendUPP = UniversalProcPtr;
  151.  
  152. CONST
  153.     uppOSACreateAppleEventProcInfo = $000FEFE0;
  154.     uppOSASendProcInfo = $003FEFE0;
  155.  
  156. FUNCTION NewOSACreateAppleEventProc(userRoutine: OSACreateAppleEventProcPtr): OSACreateAppleEventUPP;
  157.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  158.     INLINE $2E9F;
  159.     {$ENDC}
  160.  
  161. FUNCTION NewOSASendProc(userRoutine: OSASendProcPtr): OSASendUPP;
  162.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  163.     INLINE $2E9F;
  164.     {$ENDC}
  165.  
  166. FUNCTION CallOSACreateAppleEventProc(theAEEventClass: AEEventClass; theAEEventID: AEEventID; {CONST}VAR target: AEAddressDesc; returnID: INTEGER; transactionID: LONGINT; VAR result: AppleEvent; refCon: LONGINT; userRoutine: OSACreateAppleEventUPP): OSErr;
  167.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  168.     INLINE $205F, $4E90;
  169.     {$ENDC}
  170.  
  171. FUNCTION CallOSASendProc({CONST}VAR theAppleEvent: AppleEvent; VAR reply: AppleEvent; sendMode: AESendMode; sendPriority: AESendPriority; timeOutInTicks: LONGINT; idleProc: AEIdleUPP; filterProc: AEFilterUPP; refCon: LONGINT; userRoutine: OSASendUPP): OSErr;
  172.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  173.     INLINE $205F, $4E90;
  174.     {$ENDC}
  175. {*************************************************************************
  176.     Standard Script Errors
  177. **************************************************************************
  178.     It is recommended that scripting components use the following set of error
  179.     codes to signal failure when applicable.  This enables applications that
  180.     use the OSA API to deal with some class of script errors in a less than 
  181.     ad hoc manner.  Scripting components are of course encouraged to return
  182.     component-specific errors when these don't apply.
  183. *************************************************************************}
  184. {        Dynamic errors:
  185.  
  186.     These errors result from data-dependent conditions and are typically
  187.     signaled at runtime.
  188. }
  189. {
  190.         Signaled when a value can't be coerced to the desired type. Similar
  191.           to errOSATypeError except results from coercion.
  192.     }
  193.  
  194. CONST
  195.     errOSACantCoerce            = -1700;
  196.  
  197. { Signaled when an object is not found in a container }
  198.     errOSACantAccess            = -1728;
  199.  
  200. {
  201.         Signaled when an object cannot be set in a container.  Same as 
  202.           AERegistry error errAEWriteDenied.
  203.     }
  204.     errOSACantAssign            = -10006;
  205.  
  206. {
  207.         Signaled by user scripts or applications when no actual error code
  208.           is to be returned.  Simply means "an error has occurred".  Most useful
  209.           in conjunction with an error message from the application.
  210.     }
  211.     errOSAGeneralError            = -2700;
  212.  
  213. { Signaled when there is an attempt to divide by zero }
  214.     errOSADivideByZero            = -2701;
  215.  
  216. { Signaled when integer or real value is too large to be represented }
  217.     errOSANumericOverflow        = -2702;
  218.  
  219. {
  220.         Signaled when application can't be launched or when it is remote and
  221.           program linking is not enabled.
  222.     }
  223.     errOSACantLaunch            = -2703;
  224.  
  225. { Signaled when an application can't respond to AppleEvents }
  226.     errOSAAppNotHighLevelEventAware = -2704;
  227.  
  228. { Signaled when an application's terminology resource is not readable }
  229.     errOSACorruptTerminology    = -2705;
  230.  
  231. { Signaled when the runtime stack overflows }
  232.     errOSAStackOverflow            = -2706;
  233.  
  234. { Signaled when a runtime internal data structure overflows }
  235.     errOSAInternalTableOverflow    = -2707;
  236.  
  237. {
  238.         Signaled when an intrinsic limitation is exceeded for the size of 
  239.           a value or data structure.
  240.     }
  241.     errOSADataBlockTooLarge        = -2708;
  242.  
  243.     errOSACantGetTerminology    = -2709;
  244.  
  245.     errOSACantCreate            = -2710;
  246.  
  247. {        Component-specific dynamic script errors:
  248.  
  249.     The range -2720 thru -2739 is reserved for component-specific runtime errors.
  250.     (Note that error codes from different scripting components in this range will
  251.     overlap.)
  252. }
  253. {        Static errors:
  254.  
  255.     These errors comprise what are commonly thought of as parse and compile-
  256.     time errors.  However, in a dynamic system (e.g. AppleScript) any or all
  257.     of these may also occur at runtime.
  258. }
  259.  
  260. { Signaled when data was not the right type and coercion is not allowed }
  261.     errOSATypeError                = -1703;
  262.  
  263. { Signaled when a message was sent to an object that didn't handle it }
  264.     OSAMessageNotUnderstood        = -1708;
  265.  
  266. {
  267.         Signaled when a function to be returned doesn't exist.  (Probably only
  268.           useful in languages with first-class functions that distinguish between
  269.           functions and other values (two name spaces). This is different from
  270.           errOSAMessageNotUnderstood, which may be signaled when the method is
  271.           invoked.
  272.     }
  273.     OSAUndefinedHandler            = -1717;
  274.  
  275. { Signaled when a container can never have the requested object }
  276.     OSAIllegalAccess            = -1723;
  277.  
  278. { Signaled when index was out of range. Specialization of errOSACantAccess. }
  279.     OSAIllegalIndex                = -1719;
  280.  
  281. { Signaled when a range is screwy. Specialization of errOSACantAccess. }
  282.     OSAIllegalRange                = -1720;
  283.  
  284. {
  285.         Signaled when an object can never be set in a container.  Same as 
  286.           AERegistry error errAENotModifiable.
  287.     }
  288.     OSAIllegalAssign            = -10003;
  289.  
  290. {
  291.         Signaled when a syntax error occurs. (e.g. "Syntax error" or
  292.          "<this> can't go after <that>").
  293.     }
  294.     OSASyntaxError                = -2740;
  295.  
  296. {
  297.         Signaled when another form of syntax was expected. (e.g. "expected
  298.           a <type> but found <this>").
  299.     }
  300.     OSASyntaxTypeError            = -2741;
  301.  
  302. { Signaled when a name or number is too long to be parsed }
  303.     OSATokenTooLong                = -2742;
  304.  
  305. {
  306.         Signaled when a parameter is missing for a function invocation.  Note
  307.           that in some languages, this error may occur at runtime.
  308.     }
  309.     OSAMissingParameter            = -1701;
  310.  
  311. {
  312.         Signaled when function is called with the wrong number of parameters,
  313.           or a parameter pattern cannot be matched.
  314.     }
  315.     OSAParameterMismatch        = -1721;
  316.  
  317. {
  318.         Signaled when a formal parameter, local variable, or instance variable
  319.           is specified more than once.
  320.     }
  321.     OSADuplicateParameter        = -2750;
  322.  
  323. {
  324.         Signaled when a formal parameter, local variable, or instance variable
  325.           is specified more than once.
  326.     }
  327.     OSADuplicateProperty        = -2751;
  328.  
  329. {
  330.         Signaled when more than one handler is defined with the same name in 
  331.           a scope where the language doesn't allow it.
  332.     }
  333.     OSADuplicateHandler            = -2752;
  334.  
  335. { Signaled when a variable is accessed that has no value }
  336.     OSAUndefinedVariable        = -2753;
  337.  
  338. {
  339.         Signaled when a variable is declared inconsistently in the same scope,
  340.           such as both local and global.
  341.     }
  342.     OSAInconsistentDeclarations    = -2754;
  343.  
  344. {
  345.         Signaled when illegal control flow occurs in an application (no catcher
  346.           for throw, non-lexical loop exit, etc.).
  347.     }
  348.     OSAControlFlowError            = -2755;
  349.  
  350. {        Component-specific static script errors:
  351.  
  352.     The range -2760 thru -2779 is reserved for component-specific parsing and
  353.     compile-time errors. (Note that error codes from different scripting
  354.     components in this range will overlap.)
  355. }
  356. {        Dialect-specific script errors:
  357.  
  358.     The range -2780 thru -2799 is reserved for dialect specific error codes for
  359.     scripting components that support dialects. (Note that error codes from
  360.     different scripting components in this range will overlap, as well as error
  361.     codes from different dialects in the same scripting component.)
  362. }
  363. {*************************************************************************
  364.     OSA Interface Descriptions
  365. **************************************************************************
  366.     The OSA Interface is broken down into a required interface, and several
  367.     optional interfaces to support additional functionality.  A given scripting
  368.     component may choose to support only some of the optional interfaces in
  369.     addition to the basic interface.  The OSA Component Flags may be used to 
  370.     query the Component Manager to find a scripting component with a particular
  371.     capability, or determine if a particular scripting component supports a 
  372.     particular capability.
  373. *************************************************************************}
  374. { OSA Component Flags: }
  375.     kOSASupportsCompiling        = $0002;
  376.     kOSASupportsGetSource        = $0004;
  377.     kOSASupportsAECoercion        = $0008;
  378.     kOSASupportsAESending        = $0010;
  379.     kOSASupportsRecording        = $0020;
  380.     kOSASupportsConvenience        = $0040;
  381.     kOSASupportsDialects        = $0080;
  382.     kOSASupportsEventHandling    = $0100;
  383.  
  384. { Component Selectors: }
  385.     kOSASelectLoad                = $0001;
  386.     kOSASelectStore                = $0002;
  387.     kOSASelectExecute            = $0003;
  388.     kOSASelectDisplay            = $0004;
  389.     kOSASelectScriptError        = $0005;
  390.     kOSASelectDispose            = $0006;
  391.     kOSASelectSetScriptInfo        = $0007;
  392.     kOSASelectGetScriptInfo        = $0008;
  393.     kOSASelectSetActiveProc        = $0009;
  394.     kOSASelectGetActiveProc        = $000A;
  395.  
  396. { Compiling: }
  397.     kOSASelectScriptingComponentName = $0102;
  398.     kOSASelectCompile            = $0103;
  399.     kOSASelectCopyID            = $0104;
  400.  
  401. { GetSource: }
  402.     kOSASelectGetSource            = $0201;
  403.  
  404. { AECoercion: }
  405.     kOSASelectCoerceFromDesc    = $0301;
  406.     kOSASelectCoerceToDesc        = $0302;
  407.  
  408. { AESending: }
  409.     kOSASelectSetSendProc        = $0401;
  410.     kOSASelectGetSendProc        = $0402;
  411.     kOSASelectSetCreateProc        = $0403;
  412.     kOSASelectGetCreateProc        = $0404;
  413.     kOSASelectSetDefaultTarget    = $0405;
  414.  
  415. { Recording: }
  416.     kOSASelectStartRecording    = $0501;
  417.     kOSASelectStopRecording        = $0502;
  418.  
  419. { Convenience: }
  420.     kOSASelectLoadExecute        = $0601;
  421.     kOSASelectCompileExecute    = $0602;
  422.     kOSASelectDoScript            = $0603;
  423.  
  424. { Dialects: }
  425.     kOSASelectSetCurrentDialect    = $0701;
  426.     kOSASelectGetCurrentDialect    = $0702;
  427.     kOSASelectAvailableDialects    = $0703;
  428.     kOSASelectGetDialectInfo    = $0704;
  429.     kOSASelectAvailableDialectCodeList = $0705;
  430.  
  431. { Event Handling: }
  432.     kOSASelectSetResumeDispatchProc = $0801;
  433.     kOSASelectGetResumeDispatchProc = $0802;
  434.     kOSASelectExecuteEvent        = $0803;
  435.     kOSASelectDoEvent            = $0804;
  436.     kOSASelectMakeContext        = $0805;
  437.  
  438.  
  439. { scripting component specific selectors are added beginning with this value  }
  440.     kOSASelectComponentSpecificStart = $1001;
  441.  
  442.  
  443. {        Mode Flags:
  444.  
  445.     Warning: These should not conflict with the AESend mode flags in
  446.     AppleEvents.h, because we may want to use them as OSA mode flags too.
  447. }
  448.  
  449. {
  450.         This mode flag may be passed to OSALoad, OSAStore or OSACompile to
  451.           instruct the scripting component to not retain the "source" of an
  452.           expression.  This will cause the OSAGetSource call to return the error
  453.           errOSASourceNotAvailable if used.  However, some scripting components
  454.           may not retain the source anyway.  This is mainly used when either space
  455.           efficiency is desired, or a script is to be "locked" so that its
  456.           implementation may not be viewed.
  457.     }
  458.     kOSAModePreventGetSource    = $00000001;
  459.  
  460. {
  461.         These mode flags may be passed to OSACompile, OSAExecute, OSALoadExecute
  462.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  463.           indicate whether or not the script may interact with the user, switch
  464.           layer or reconnect if necessary.  Any AppleEvents will be sent with the
  465.           corresponding AESend mode supplied.
  466.     }
  467.     kOSAModeNeverInteract        = $00000010;
  468.     kOSAModeCanInteract            = $00000020;
  469.     kOSAModeAlwaysInteract        = $00000030;
  470.     kOSAModeDontReconnect        = $00000080;
  471.  
  472. {
  473.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  474.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  475.           indicate whether or not AppleEvents should be sent with the
  476.           kAECanSwitchLayer mode flag sent or not. NOTE: This flag is exactly the
  477.           opposite sense of the AppleEvent flag kAECanSwitchLayer.  This is to
  478.           provide a more convenient default, i.e. not supplying any mode
  479.           (kOSAModeNull) means to send events with kAECanSwitchLayer.  Supplying
  480.           the kOSAModeCantSwitchLayer mode flag will cause AESend to be called
  481.           without kAECanSwitchLayer.
  482.     }
  483.     kOSAModeCantSwitchLayer        = $00000040;
  484.  
  485. {
  486.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  487.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  488.           indicate whether or not AppleEvents should be sent with the kAEDontRecord
  489.           mode flag sent or not. NOTE: This flag is exactly the opposite sense of
  490.           the AppleEvent flag kAEDontRecord.  This is to provide a more convenient
  491.           default, i.e. not supplying any mode (kOSAModeNull) means to send events
  492.           with kAEDontRecord.  Supplying the kOSAModeDoRecord mode flag will 
  493.           cause AESend to be called without kAEDontRecord.
  494.     }
  495.     kOSAModeDoRecord            = $00001000;
  496.  
  497. {
  498.         This is a mode flag for OSACompile that indicates that a context should
  499.           be created as the result of compilation. All handler definitions are
  500.           inserted into the new context, and variables are initialized by
  501.           evaluating their initial values in a null context (i.e. they must be
  502.           constant expressions).
  503.     }
  504.     kOSAModeCompileIntoContext    = $00000002;
  505.  
  506. {
  507.         This is a mode flag for OSACompile that indicates that the previous
  508.           script ID (input to OSACompile) should be augmented with any new
  509.           definitions in the sourceData rather than replaced with a new script.
  510.           This means that the previous script ID must designate a context.
  511.           The presence of this flag causes the kOSAModeCompileIntoContext flag
  512.           to be implicitly used, causing any new definitions to be initialized
  513.           in a null context.
  514.     }
  515.     kOSAModeAugmentContext        = $00000004;
  516.  
  517. {
  518.         This mode flag may be passed to OSADisplay or OSADoScript to indicate
  519.           that output only need be human-readable, not re-compilable by OSACompile.
  520.           If used, output may be arbitrarily "beautified", e.g. quotes may be left
  521.           off of string values, long lists may have elipses, etc.
  522.     }
  523.     kOSAModeDisplayForHumans    = $00000008;
  524.  
  525. {
  526.         This mode flag may be passed to OSAStore in the case where the scriptID
  527.           is a context.  This causes the context to be saved, but not the context's
  528.           parent context.  When the stored context is loaded back in, the parent
  529.           will be kOSANullScript.
  530.     }
  531.     kOSAModeDontStoreParent        = $00010000;
  532.  
  533. {
  534.         This mode flag may be passed to OSAExecuteEvent to cause the event to
  535.           be dispatched to the direct object of the event. The direct object (or
  536.           subject attribute if the direct object is a non-object specifier) will
  537.           be resolved, and the resulting script object will be the recipient of
  538.           the message. The context argument to OSAExecuteEvent will serve as the
  539.           root of the lookup/resolution process.
  540.     }
  541.     kOSAModeDispatchToDirectObject = $00020000;
  542.  
  543. {
  544.         This mode flag may be passed to OSAExecuteEvent to indicate that
  545.           components do not have to get the data of object specifier arguments.
  546.     }
  547.     kOSAModeDontGetDataForArguments = $00040000;
  548.  
  549. {*************************************************************************
  550.     OSA Basic Scripting Interface
  551. **************************************************************************
  552.     Scripting components must at least support the Basic Scripting interface.
  553. *************************************************************************}
  554. {        Loading and Storing Scripts:
  555.  
  556.     These routines allow scripts to be loaded and stored in their internal
  557.     (possibly compiled, non-text) representation.
  558. }
  559.  
  560. { Resource type for scripts }
  561.     kOSAScriptResourceType        = 'scpt';
  562.  
  563. {
  564.         Default type given to OSAStore which creates "generic" loadable script
  565.           data descriptors.
  566.     }
  567.     typeOSAGenericStorage        = 'scpt';
  568.  
  569. FUNCTION OSALoad(scriptingComponent: ComponentInstance; {CONST}VAR scriptData: AEDesc; modeFlags: LONGINT; VAR resultingScriptID: OSAID): OSAError;
  570.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  571.     INLINE $2F3C, $000C, $0001, $7000, $A82A;
  572.     {$ENDC}
  573. {
  574.         OSAComponentFunctionInline(kOSASelectLoad, 12);
  575.     
  576.         Errors:
  577.             badComponentInstance        invalid scripting component instance
  578.             errOSASystemError
  579.             errOSABadStorageType:        scriptData not for this scripting component
  580.             errOSACorruptData:            data seems to be corrupt
  581.             errOSADataFormatObsolete    script data format is no longer supported
  582.             errOSADataFormatTooNew        script data format is from a newer version
  583.         
  584.         ModeFlags:
  585.             kOSAModePreventGetSource
  586.     }
  587. FUNCTION OSAStore(scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR resultingScriptData: AEDesc): OSAError;
  588.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  589.     INLINE $2F3C, $0010, $0002, $7000, $A82A;
  590.     {$ENDC}
  591. {
  592.         OSAComponentFunctionInline(kOSASelectStore, 16);
  593.     
  594.         Errors:
  595.             badComponentInstance    invalid scripting component instance
  596.             errOSASystemError
  597.             errOSAInvalidID
  598.             errOSABadStorageType:    desiredType not for this scripting component
  599.         
  600.         ModeFlags:
  601.             kOSAModePreventGetSource
  602.             kOSAModeDontStoreParent
  603.     }
  604. { Executing Scripts: }
  605. FUNCTION OSAExecute(scriptingComponent: ComponentInstance; compiledScriptID: OSAID; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  606.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  607.     INLINE $2F3C, $0010, $0003, $7000, $A82A;
  608.     {$ENDC}
  609. {
  610.         OSAComponentFunctionInline(kOSASelectExecute, 16);
  611.         This call runs a script.  The contextID represents the environment
  612.         with which global variables in the script are resolved.  The constant
  613.         kOSANullScript may be used for the contextID if the application wishes
  614.         to not deal with context directly (a default one is associated with each
  615.         scripting component instance).  The resultingScriptValueID is the 
  616.         result of evaluation, and contains a value which may be displayed using
  617.         the OSAGetSource call.  The modeFlags convey scripting component
  618.         specific information.
  619.     
  620.         Errors:
  621.             badComponentInstance    invalid scripting component instance
  622.             errOSASystemError
  623.             errOSAInvalidID
  624.             errOSAScriptError:        the executing script got an error
  625.     
  626.         ModeFlags:
  627.             kOSAModeNeverInteract
  628.             kOSAModeCanInteract
  629.             kOSAModeAlwaysInteract
  630.             kOSAModeCantSwitchLayer
  631.             kOSAModeDontReconnect
  632.             kOSAModeDoRecord
  633.     }
  634. { Displaying results: }
  635. FUNCTION OSADisplay(scriptingComponent: ComponentInstance; scriptValueID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR resultingText: AEDesc): OSAError;
  636.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  637.     INLINE $2F3C, $0010, $0004, $7000, $A82A;
  638.     {$ENDC}
  639. {
  640.         OSAComponentFunctionInline(kOSASelectDisplay, 16);
  641.         This call is used to convert results (script value IDs) into displayable
  642.         text. The desiredType should be at least typeChar, and modeFlags are
  643.         scripting system specific flags to control the formatting of the
  644.         resulting text. This call differs from OSAGetSource in that (1) it
  645.         always produces at least typeChar, (2) is only works on script values,
  646.         (3) it may display it's output in non-compilable form (e.g. without
  647.         string quotes, elipses inserted in long and/or circular lists, etc.) and
  648.         (4) it is required by the basic scripting interface.
  649.     
  650.         Errors:
  651.             badComponentInstance    invalid scripting component instance
  652.             errOSASystemError
  653.             errOSAInvalidID
  654.             errAECoercionFail:        desiredType not supported by scripting component
  655.     
  656.         ModeFlags:
  657.             kOSAModeDisplayForHumans
  658.     }
  659. { Getting Error Information: }
  660. FUNCTION OSAScriptError(scriptingComponent: ComponentInstance; selector: OSType; desiredType: DescType; VAR resultingErrorDescription: AEDesc): OSAError;
  661.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  662.     INLINE $2F3C, $000C, $0005, $7000, $A82A;
  663.     {$ENDC}
  664. {
  665.         OSAComponentFunctionInline(kOSASelectScriptError, 12);
  666.         Whenever script execution returns errOSAExecutionError, this routine
  667.         may be used to get information about that error.  The selector describes
  668.         the type of information desired about the error (various selectors are
  669.         listed below).  The desiredType indicates the data type of the result
  670.         desired for that selector.
  671.     
  672.         Errors:
  673.             badComponentInstance    invalid scripting component instance
  674.             errOSASystemError
  675.             errOSABadSelector:        selector not supported by scripting component
  676.             errAECoercionFail:        desiredType not supported by scripting component
  677.     }
  678. { OSAScriptError selectors: }
  679. {
  680.         This selector is used to determine the error number of a script error.
  681.         These error numbers may be either system error numbers, or error numbers
  682.         that are scripting component specific.
  683.         Required desiredTypes:    
  684.               typeShortInteger
  685.     }
  686.  
  687. CONST
  688.     kOSAErrorNumber                = 'errn';
  689.  
  690. {
  691.         This selector is used to determine the full error message associated
  692.         with the error number.  It should include the name of the application
  693.         which caused the error, as well as the specific error that occurred.
  694.         This selector is sufficient for simple error reporting (but see
  695.         kOSAErrorBriefMessage, below).
  696.         Required desiredTypes:
  697.             typeChar                    error message string
  698.     }
  699.     kOSAErrorMessage            = 'errs';
  700.  
  701. {
  702.         This selector is used to determine a brief error message associated with
  703.         the error number.  This message and should not mention the name of the
  704.         application which caused the error, any partial results or offending
  705.         object (see kOSAErrorApp, kOSAErrorPartialResult and
  706.         kOSAErrorOffendingObject, below).
  707.         Required desiredTypes:
  708.               typeChar                    brief error message string
  709.     }
  710. {  0x65727262  }
  711.     kOSAErrorBriefMessage        = 'errb';
  712.  
  713. {
  714.         This selector is used to determine which application actually got the
  715.         error (if it was the result of an AESend), or the current application
  716.         if ....
  717.         Required desiredTypes:
  718.               typeProcessSerialNumber        PSN of the errant application
  719.               typeChar                    name of the errant application
  720.     }
  721. {  0x65726170  }
  722.     kOSAErrorApp                = 'erap';
  723.  
  724. {
  725.         This selector is used to determine any partial result returned by an 
  726.         operation. If an AESend call failed, but a partial result was returned,
  727.         then the partial result may be returned as an AEDesc.
  728.         Required desiredTypes:
  729.               typeBest                    AEDesc of any partial result
  730.     }
  731. {  0x70746c72   }
  732.     kOSAErrorPartialResult        = 'ptlr';
  733.  
  734. {
  735.         This selector is used to determine any object which caused the error
  736.         that may have been indicated by an application.  The result is an 
  737.         AEDesc.
  738.         Required desiredTypes:
  739.               typeBest                    AEDesc of any offending object
  740.     }
  741. {  0x65726f62   }
  742.     kOSAErrorOffendingObject    = 'erob';
  743.  
  744. {
  745.         This selector is used to determine the type expected by a coercion 
  746.         operation if a type error occurred.
  747.     }
  748. {  0x65727274   }
  749.     kOSAErrorExpectedType        = 'errt';
  750.  
  751. {
  752.         This selector is used to determine the source text range (start and 
  753.         end positions) of where the error occurred.
  754.         Required desiredTypes:
  755.               typeOSAErrorRange
  756.     }
  757. {  0x65726e67  }
  758.     kOSAErrorRange                = 'erng';
  759.  
  760. {
  761.         An AERecord type containing keyOSASourceStart and keyOSASourceEnd fields
  762.         of type short.
  763.     }
  764. {  0x65726e67   }
  765.     typeOSAErrorRange            = 'erng';
  766.  
  767. { Field of a typeOSAErrorRange record of typeShortInteger }
  768. {  0x73726373    }
  769.     keyOSASourceStart            = 'srcs';
  770.  
  771. { Field of a typeOSAErrorRange record of typeShortInteger }
  772. {  0x73726365   }
  773.     keyOSASourceEnd                = 'srce';
  774.  
  775. { Disposing Script IDs: }
  776. FUNCTION OSADispose(scriptingComponent: ComponentInstance; scriptID: OSAID): OSAError;
  777.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  778.     INLINE $2F3C, $0004, $0006, $7000, $A82A;
  779.     {$ENDC}
  780. {
  781.         OSAComponentFunctionInline(kOSASelectDispose, 4);
  782.         Disposes a script or context.
  783.     
  784.         Errors:
  785.             badComponentInstance    invalid scripting component instance
  786.             errOSASystemError
  787.             errOSAInvalidID
  788.     }
  789. { Getting and Setting Script Information: }
  790. FUNCTION OSASetScriptInfo(scriptingComponent: ComponentInstance; scriptID: OSAID; selector: OSType; value: LONGINT): OSAError;
  791.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  792.     INLINE $2F3C, $000C, $0007, $7000, $A82A;
  793.     {$ENDC}
  794. {
  795.         OSAComponentFunctionInline(kOSASelectSetScriptInfo, 12);
  796.     
  797.         Errors:
  798.             badComponentInstance    invalid scripting component instance
  799.             errOSASystemError
  800.             errOSAInvalidID
  801.             errOSABadSelector:        selector not supported by scripting component
  802.                                     or selector not for this scriptID
  803.     }
  804. FUNCTION OSAGetScriptInfo(scriptingComponent: ComponentInstance; scriptID: OSAID; selector: OSType; VAR result: LONGINT): OSAError;
  805.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  806.     INLINE $2F3C, $000C, $0008, $7000, $A82A;
  807.     {$ENDC}
  808. {
  809.         OSAComponentFunctionInline(kOSASelectGetScriptInfo, 12);
  810.     
  811.         Errors:
  812.             badComponentInstance    invalid scripting component instance
  813.             errOSASystemError
  814.             errOSAInvalidID
  815.             errOSABadSelector:        selector not supported by scripting component
  816.                                     or selector not for this scriptID
  817.     }
  818. { Manipulating the ActiveProc:
  819.  
  820.     Scripting systems will supply default values for these procedures if they
  821.     are not set by the client:
  822. }
  823.  
  824. TYPE
  825. {$IFC TYPED_FUNCTION_POINTERS}
  826.     OSAActiveProcPtr = FUNCTION(refCon: LONGINT): OSErr;
  827. {$ELSEC}
  828.     OSAActiveProcPtr = ProcPtr;
  829. {$ENDC}
  830.  
  831.     OSAActiveUPP = UniversalProcPtr;
  832.  
  833. CONST
  834.     uppOSAActiveProcInfo = $000000E0;
  835.  
  836. FUNCTION NewOSAActiveProc(userRoutine: OSAActiveProcPtr): OSAActiveUPP;
  837.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  838.     INLINE $2E9F;
  839.     {$ENDC}
  840.  
  841. FUNCTION CallOSAActiveProc(refCon: LONGINT; userRoutine: OSAActiveUPP): OSErr;
  842.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  843.     INLINE $205F, $4E90;
  844.     {$ENDC}
  845. FUNCTION OSASetActiveProc(scriptingComponent: ComponentInstance; activeProc: OSAActiveUPP; refCon: LONGINT): OSAError;
  846.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  847.     INLINE $2F3C, $0008, $0009, $7000, $A82A;
  848.     {$ENDC}
  849. {
  850.         OSAComponentFunctionInline(kOSASelectSetActiveProc, 8);
  851.         If activeProc is nil, the default activeProc is used.
  852.     
  853.         Errors:
  854.             badComponentInstance    invalid scripting component instance
  855.             errOSASystemError
  856.     }
  857. FUNCTION OSAGetActiveProc(scriptingComponent: ComponentInstance; VAR activeProc: OSAActiveUPP; VAR refCon: LONGINT): OSAError;
  858.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  859.     INLINE $2F3C, $0008, $000A, $7000, $A82A;
  860.     {$ENDC}
  861. {
  862.         OSAComponentFunctionInline(kOSASelectGetActiveProc, 8);
  863.     
  864.         Errors:
  865.             badComponentInstance    invalid scripting component instance
  866.             errOSASystemError
  867.     }
  868. {*************************************************************************
  869.     OSA Optional Compiling Interface
  870. **************************************************************************
  871.     Scripting components that support the Compiling interface have the 
  872.     kOSASupportsCompiling bit set in it's ComponentDescription.
  873. *************************************************************************}
  874. FUNCTION OSAScriptingComponentName(scriptingComponent: ComponentInstance; VAR resultingScriptingComponentName: AEDesc): OSAError;
  875.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  876.     INLINE $2F3C, $0004, $0102, $7000, $A82A;
  877.     {$ENDC}
  878. {
  879.         OSAComponentFunctionInline(kOSASelectScriptingComponentName, 4);
  880.         Given a scripting component, this routine returns the name of that
  881.         scripting component in a type that is coercable to text (typeChar).
  882.         The generic scripting component returns the name of the default
  883.         scripting component.  This name should be sufficient to convey to the
  884.         user the kind of script (syntax) he is expected to write.
  885.     
  886.         Errors:
  887.             badComponentInstance    invalid scripting component instance
  888.             errOSASystemError
  889.     }
  890. FUNCTION OSACompile(scriptingComponent: ComponentInstance; {CONST}VAR sourceData: AEDesc; modeFlags: LONGINT; VAR previousAndResultingScriptID: OSAID): OSAError;
  891.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  892.     INLINE $2F3C, $000C, $0103, $7000, $A82A;
  893.     {$ENDC}
  894. {
  895.         OSAComponentFunctionInline(kOSASelectCompile, 12);
  896.         Coerces input desc (possibly text) into a script's internal format.
  897.         Once compiled, the script is ready to run.  The modeFlags convey
  898.         scripting component specific information.  The previous script ID
  899.         (result parameter) is made to refer to the newly compiled script,
  900.         unless it was originally kOSANullScript.  In this case a new script
  901.         ID is created and used.
  902.     
  903.         Errors:
  904.             badComponentInstance    invalid scripting component instance
  905.             errOSASystemError
  906.             errAECoercionFail:        sourceData is not compilable
  907.             errOSAScriptError:        sourceData was a bad script (syntax error)
  908.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  909.                                     valid on input
  910.     
  911.         ModeFlags:
  912.             kOSAModePreventGetSource
  913.             kOSAModeCompileIntoContext
  914.             kOSAModeAugmentContext
  915.             kOSAModeNeverInteract
  916.             kOSAModeCanInteract
  917.             kOSAModeAlwaysInteract
  918.             kOSAModeCantSwitchLayer
  919.             kOSAModeDontReconnect
  920.             kOSAModeDoRecord
  921.     }
  922. FUNCTION OSACopyID(scriptingComponent: ComponentInstance; fromID: OSAID; VAR toID: OSAID): OSAError;
  923.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  924.     INLINE $2F3C, $0008, $0104, $7000, $A82A;
  925.     {$ENDC}
  926. {
  927.         OSAComponentFunctionInline(kOSASelectCopyID, 8);
  928.         If toID is a reference to kOSANullScript then it is updated to have a
  929.         new scriptID value.  This call can be used to perform undo or revert
  930.         operations on scripts. 
  931.     
  932.         Errors:
  933.             badComponentInstance    invalid scripting component instance
  934.             errOSASystemError
  935.             errOSAInvalidID
  936.     }
  937. {*************************************************************************
  938.     OSA Optional GetSource Interface
  939. **************************************************************************
  940.     Scripting components that support the GetSource interface have the 
  941.     kOSASupportsGetSource bit set in it's ComponentDescription.
  942. *************************************************************************}
  943. FUNCTION OSAGetSource(scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; VAR resultingSourceData: AEDesc): OSAError;
  944.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  945.     INLINE $2F3C, $000C, $0201, $7000, $A82A;
  946.     {$ENDC}
  947. {
  948.         OSAComponentFunctionInline(kOSASelectGetSource, 12);
  949.         This routine causes a compiled script to be output in a form (possibly
  950.         text) such that it is suitable to be passed back to OSACompile.
  951.  
  952.         Errors:
  953.             badComponentInstance    invalid scripting component instance
  954.             errOSASystemError
  955.             errOSAInvalidID
  956.             errOSASourceNotAvailable    can't get source for this scriptID
  957.     }
  958. {*************************************************************************
  959.     OSA Optional AECoercion Interface
  960. **************************************************************************
  961.     Scripting components that support the AECoercion interface have the 
  962.     kOSASupportsAECoercion bit set in it's ComponentDescription.
  963. *************************************************************************}
  964. FUNCTION OSACoerceFromDesc(scriptingComponent: ComponentInstance; {CONST}VAR scriptData: AEDesc; modeFlags: LONGINT; VAR resultingScriptID: OSAID): OSAError;
  965.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  966.     INLINE $2F3C, $000C, $0301, $7000, $A82A;
  967.     {$ENDC}
  968. {
  969.         OSAComponentFunctionInline(kOSASelectCoerceFromDesc, 12);
  970.         This routine causes script data to be coerced into a script value.
  971.         If the scriptData is an AppleEvent, then the resultingScriptID is a
  972.         compiled script ID (mode flags for OSACompile may be used in this case).
  973.         Other scriptData descriptors create script value IDs.
  974.     
  975.         Errors:
  976.             badComponentInstance    invalid scripting component instance
  977.             errOSASystemError
  978.     
  979.         ModeFlags:
  980.             kOSAModePreventGetSource
  981.             kOSAModeCompileIntoContext
  982.             kOSAModeNeverInteract
  983.             kOSAModeCanInteract
  984.             kOSAModeAlwaysInteract
  985.             kOSAModeCantSwitchLayer
  986.             kOSAModeDontReconnect
  987.             kOSAModeDoRecord
  988.     }
  989. FUNCTION OSACoerceToDesc(scriptingComponent: ComponentInstance; scriptID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR result: AEDesc): OSAError;
  990.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  991.     INLINE $2F3C, $0010, $0302, $7000, $A82A;
  992.     {$ENDC}
  993. {
  994.         OSAComponentFunctionInline(kOSASelectCoerceToDesc, 16);
  995.         This routine causes a script value to be coerced into any desired form.
  996.         If the scriptID denotes a compiled script, then it may be coerced to 
  997.         typeAppleEvent.
  998.     
  999.         Errors:
  1000.             badComponentInstance    invalid scripting component instance
  1001.             errOSASystemError
  1002.             errOSAInvalidID
  1003.     }
  1004. {*************************************************************************
  1005.     OSA Optional AESending Interface
  1006. **************************************************************************
  1007.     Scripting components that support the AESending interface have the 
  1008.     kOSASupportsAESending bit set in it's ComponentDescription.
  1009. *************************************************************************}
  1010. {
  1011.     Scripting systems will supply default values for these procedures if they
  1012.     are not set by the client:
  1013. }
  1014. FUNCTION OSASetSendProc(scriptingComponent: ComponentInstance; sendProc: OSASendUPP; refCon: LONGINT): OSAError;
  1015.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1016.     INLINE $2F3C, $0008, $0401, $7000, $A82A;
  1017.     {$ENDC}
  1018. {
  1019.         OSAComponentFunctionInline(kOSASelectSetSendProc, 8);
  1020.         If sendProc is nil, the default sendProc is used.
  1021.     
  1022.         Errors:
  1023.             badComponentInstance    invalid scripting component instance
  1024.             errOSASystemError
  1025.     }
  1026. FUNCTION OSAGetSendProc(scriptingComponent: ComponentInstance; VAR sendProc: OSASendUPP; VAR refCon: LONGINT): OSAError;
  1027.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1028.     INLINE $2F3C, $0008, $0402, $7000, $A82A;
  1029.     {$ENDC}
  1030. {
  1031.         OSAComponentFunctionInline(kOSASelectGetSendProc, 8);
  1032.     
  1033.         Errors:
  1034.             badComponentInstance    invalid scripting component instance
  1035.             errOSASystemError
  1036.     }
  1037. FUNCTION OSASetCreateProc(scriptingComponent: ComponentInstance; createProc: OSACreateAppleEventUPP; refCon: LONGINT): OSAError;
  1038.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1039.     INLINE $2F3C, $0008, $0403, $7000, $A82A;
  1040.     {$ENDC}
  1041. {
  1042.         OSAComponentFunctionInline(kOSASelectSetCreateProc, 8);
  1043.         If createProc is nil, the default createProc is used.
  1044.     
  1045.         Errors:
  1046.             badComponentInstance    invalid scripting component instance
  1047.             errOSASystemError
  1048.     }
  1049. FUNCTION OSAGetCreateProc(scriptingComponent: ComponentInstance; VAR createProc: OSACreateAppleEventUPP; VAR refCon: LONGINT): OSAError;
  1050.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1051.     INLINE $2F3C, $0008, $0404, $7000, $A82A;
  1052.     {$ENDC}
  1053. {
  1054.         OSAComponentFunctionInline(kOSASelectGetCreateProc, 8);
  1055.     
  1056.         Errors:
  1057.             badComponentInstance    invalid scripting component instance
  1058.             errOSASystemError
  1059.     }
  1060. FUNCTION OSASetDefaultTarget(scriptingComponent: ComponentInstance; {CONST}VAR target: AEAddressDesc): OSAError;
  1061.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1062.     INLINE $2F3C, $0004, $0405, $7000, $A82A;
  1063.     {$ENDC}
  1064. {
  1065.         OSAComponentFunctionInline(kOSASelectSetDefaultTarget, 4);
  1066.         This routine sets the default target application for AE sending.
  1067.         It also establishes the default target from which terminologies come.
  1068.         It is effectively like having an AppleScript "tell" statement around
  1069.         the entire program.  If this routine is not called, or if the target 
  1070.         is a null AEDesc, then the current application is the default target.
  1071.     
  1072.         Errors:
  1073.             badComponentInstance    invalid scripting component instance
  1074.             errOSASystemError
  1075.     }
  1076. {*************************************************************************
  1077.     OSA Optional Recording Interface
  1078. **************************************************************************
  1079.     Scripting components that support the Recording interface have the 
  1080.     kOSASupportsRecording bit set in it's ComponentDescription.
  1081. *************************************************************************}
  1082. FUNCTION OSAStartRecording(scriptingComponent: ComponentInstance; VAR compiledScriptToModifyID: OSAID): OSAError;
  1083.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1084.     INLINE $2F3C, $0004, $0501, $7000, $A82A;
  1085.     {$ENDC}
  1086. {
  1087.         OSAComponentFunctionInline(kOSASelectStartRecording, 4);
  1088.         Starts recording.  If compiledScriptToModifyID is kOSANullScript, a
  1089.         new script ID is created and returned.  If the current application has
  1090.         a handler for the kOSARecordedText event, then kOSARecordedText events
  1091.         are sent to the application containing the text of each AppleEvent 
  1092.         recorded.
  1093.     
  1094.         Errors:
  1095.             badComponentInstance    invalid scripting component instance
  1096.             errOSASystemError
  1097.             errOSAInvalidID
  1098.             errOSARecordingIsAlreadyOn
  1099.     }
  1100. FUNCTION OSAStopRecording(scriptingComponent: ComponentInstance; compiledScriptID: OSAID): OSAError;
  1101.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1102.     INLINE $2F3C, $0004, $0502, $7000, $A82A;
  1103.     {$ENDC}
  1104. {
  1105.         OSAComponentFunctionInline(kOSASelectStopRecording, 4);
  1106.         If compiledScriptID is not being recorded into or recording is not
  1107.         currently on, no error is returned.
  1108.     
  1109.         Errors:
  1110.             badComponentInstance    invalid scripting component instance
  1111.             errOSASystemError
  1112.             errOSAInvalidID
  1113.     }
  1114. {*************************************************************************
  1115.     OSA Optional Convenience Interface
  1116. **************************************************************************
  1117.     Scripting components that support the Convenience interface have the 
  1118.     kOSASupportsConvenience bit set in it's ComponentDescription.
  1119. *************************************************************************}
  1120. FUNCTION OSALoadExecute(scriptingComponent: ComponentInstance; {CONST}VAR scriptData: AEDesc; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1121.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1122.     INLINE $2F3C, $0010, $0601, $7000, $A82A;
  1123.     {$ENDC}
  1124. {
  1125.         OSAComponentFunctionInline(kOSASelectLoadExecute, 16);
  1126.         This routine is effectively equivalent to calling OSALoad followed by
  1127.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1128.         resulting value ID is retained.
  1129.     
  1130.         Errors:
  1131.             badComponentInstance        invalid scripting component instance
  1132.             errOSASystemError
  1133.             errOSABadStorageType:        scriptData not for this scripting component
  1134.             errOSACorruptData:            data seems to be corrupt
  1135.             errOSADataFormatObsolete    script data format is no longer supported
  1136.             errOSADataFormatTooNew        script data format is from a newer version
  1137.             errOSAInvalidID
  1138.             errOSAScriptError:            the executing script got an error
  1139.     
  1140.         ModeFlags:
  1141.             kOSAModeNeverInteract
  1142.             kOSAModeCanInteract
  1143.             kOSAModeAlwaysInteract
  1144.             kOSAModeCantSwitchLayer
  1145.             kOSAModeDontReconnect
  1146.             kOSAModeDoRecord
  1147.     }
  1148. FUNCTION OSACompileExecute(scriptingComponent: ComponentInstance; {CONST}VAR sourceData: AEDesc; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1149.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1150.     INLINE $2F3C, $0010, $0602, $7000, $A82A;
  1151.     {$ENDC}
  1152. {
  1153.         OSAComponentFunctionInline(kOSASelectCompileExecute, 16);
  1154.         This routine is effectively equivalent to calling OSACompile followed by
  1155.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1156.         resulting value ID is retained.
  1157.     
  1158.         Errors:
  1159.             badComponentInstance    invalid scripting component instance
  1160.             errOSASystemError
  1161.             errAECoercionFail:        sourceData is not compilable
  1162.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1163.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1164.                                     valid on input
  1165.             errOSAScriptError:        the executing script got an error
  1166.     
  1167.         ModeFlags:
  1168.             kOSAModeNeverInteract
  1169.             kOSAModeCanInteract
  1170.             kOSAModeAlwaysInteract
  1171.             kOSAModeCantSwitchLayer
  1172.             kOSAModeDontReconnect
  1173.             kOSAModeDoRecord
  1174.     }
  1175. FUNCTION OSADoScript(scriptingComponent: ComponentInstance; {CONST}VAR sourceData: AEDesc; contextID: OSAID; desiredType: DescType; modeFlags: LONGINT; VAR resultingText: AEDesc): OSAError;
  1176.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1177.     INLINE $2F3C, $0014, $0603, $7000, $A82A;
  1178.     {$ENDC}
  1179. {
  1180.         OSAComponentFunctionInline(kOSASelectDoScript, 20);
  1181.         This routine is effectively equivalent to calling OSACompile followed by
  1182.         OSAExecute and then OSADisplay.  After execution, the compiled source
  1183.         and the resulting value are is disposed.  Only the resultingText
  1184.         descriptor is retained.  If a script error occur during processing, the 
  1185.         resultingText gets the error message of the error, and errOSAScriptError
  1186.         is returned.  OSAScriptError may still be used to extract more 
  1187.         information about the particular error.
  1188.     
  1189.         Errors:
  1190.             badComponentInstance    invalid scripting component instance
  1191.             errOSASystemError
  1192.             errAECoercionFail:        sourceData is not compilable or 
  1193.                                     desiredType not supported by scripting component
  1194.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1195.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1196.                                     valid on input
  1197.             errOSAScriptError:        the executing script got an error
  1198.     
  1199.         ModeFlags:
  1200.             kOSAModeNeverInteract
  1201.             kOSAModeCanInteract
  1202.             kOSAModeAlwaysInteract
  1203.             kOSAModeCantSwitchLayer
  1204.             kOSAModeDontReconnect
  1205.             kOSAModeDoRecord
  1206.             kOSAModeDisplayForHumans
  1207.     }
  1208. {*************************************************************************
  1209.     OSA Optional Dialects Interface
  1210. **************************************************************************
  1211.     Scripting components that support the Dialects interface have the 
  1212.     kOSASupportsDialects bit set in it's ComponentDescription.
  1213. *************************************************************************}
  1214. {
  1215.     These calls allows an scripting component that supports different dialects
  1216.     to dynamically switch between those dialects.  Although this interface is
  1217.     specified, the particular dialect codes are scripting component dependent.
  1218. }
  1219. FUNCTION OSASetCurrentDialect(scriptingComponent: ComponentInstance; dialectCode: INTEGER): OSAError;
  1220.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1221.     INLINE $2F3C, $0002, $0701, $7000, $A82A;
  1222.     {$ENDC}
  1223. {
  1224.         OSAComponentFunctionInline(kOSASelectSetCurrentDialect, 2);
  1225.     
  1226.         Errors:
  1227.             badComponentInstance    invalid scripting component instance
  1228.             errOSASystemError
  1229.             errOSANoSuchDialect:    invalid dialectCode
  1230.     }
  1231. FUNCTION OSAGetCurrentDialect(scriptingComponent: ComponentInstance; VAR resultingDialectCode: INTEGER): OSAError;
  1232.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1233.     INLINE $2F3C, $0004, $0702, $7000, $A82A;
  1234.     {$ENDC}
  1235. {
  1236.         OSAComponentFunctionInline(kOSASelectGetCurrentDialect, 4);
  1237.     
  1238.         Errors:
  1239.             badComponentInstance    invalid scripting component instance
  1240.             errOSASystemError
  1241.     }
  1242. FUNCTION OSAAvailableDialects(scriptingComponent: ComponentInstance; VAR resultingDialectInfoList: AEDesc): OSAError;
  1243.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1244.     INLINE $2F3C, $0004, $0703, $7000, $A82A;
  1245.     {$ENDC}
  1246. {
  1247.         OSAComponentFunctionInline(kOSASelectAvailableDialects, 4);
  1248.         This call return an AEList containing information about each of the
  1249.         currently available dialects of a scripting component.  Each item
  1250.         is an AERecord of typeOSADialectInfo that contains at least the fields
  1251.         keyOSADialectName, keyOSADialectCode, KeyOSADialectLangCode and 
  1252.         keyOSADialectScriptCode.
  1253.     
  1254.         Errors:
  1255.             badComponentInstance    invalid scripting component instance
  1256.             errOSASystemError
  1257.     }
  1258. FUNCTION OSAGetDialectInfo(scriptingComponent: ComponentInstance; dialectCode: INTEGER; selector: OSType; VAR resultingDialectInfo: AEDesc): OSAError;
  1259.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1260.     INLINE $2F3C, $000A, $0704, $7000, $A82A;
  1261.     {$ENDC}
  1262. {
  1263.         OSAComponentFunctionInline(kOSASelectGetDialectInfo, 10);
  1264.         This call gives information about the specified dialect of a scripting
  1265.         component. It returns an AEDesc whose type depends on the selector 
  1266.         specified. Available selectors are the same as the field keys for a
  1267.         dialect info record. The type of AEDesc returned is the same as the 
  1268.         type of the field that has same key as the selector.
  1269.     
  1270.         Errors:
  1271.             badComponentInstance    invalid scripting component instance
  1272.             errOSASystemError
  1273.              errOSABadSelector
  1274.             errOSANoSuchDialect:    invalid dialectCode
  1275.     }
  1276. FUNCTION OSAAvailableDialectCodeList(scriptingComponent: ComponentInstance; VAR resultingDialectCodeList: AEDesc): OSAError;
  1277.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1278.     INLINE $2F3C, $0004, $0705, $7000, $A82A;
  1279.     {$ENDC}
  1280. {
  1281.         OSAComponentFunctionInline(kOSASelectAvailableDialectCodeList, 4);
  1282.         This is alternative to OSAGetAvailableDialectCodeList. Use this call
  1283.         and  OSAGetDialectInfo to get information on dialects.
  1284.         This call return an AEList containing dialect code for each of the
  1285.         currently available dialects of a scripting component. Each dialect
  1286.         code is a short integer of type typeShortInteger.
  1287.     
  1288.         Errors:
  1289.             badComponentInstance    invalid scripting component instance
  1290.             errOSASystemError
  1291.  
  1292.         Type of a dialect info record containing at least keyOSADialectName
  1293.         and keyOSADialectCode fields.
  1294.  
  1295.         keys for dialect info record, also used as selectors to OSAGetDialectInfo.
  1296.  
  1297.         Field of a typeOSADialectInfo record of typeChar.
  1298.         Field of a typeOSADialectInfo record of typeShortInteger.
  1299.         Field of a typeOSADialectInfo record of typeShortInteger.
  1300.         Field of a typeOSADialectInfo record of typeShortInteger.
  1301.     }
  1302. {*************************************************************************
  1303.     OSA Optional Event Handling Interface
  1304. **************************************************************************
  1305.     Scripting components that support the Event Handling interface have the 
  1306.     kOSASupportsEventHandling bit set in it's ComponentDescription.
  1307. *************************************************************************}
  1308. FUNCTION OSASetResumeDispatchProc(scriptingComponent: ComponentInstance; resumeDispatchProc: AEEventHandlerUPP; refCon: LONGINT): OSAError;
  1309.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1310.     INLINE $2F3C, $0008, $0801, $7000, $A82A;
  1311.     {$ENDC}
  1312. {
  1313.         OSAComponentFunctionInline(kOSASelectSetResumeDispatchProc, 8);
  1314.         This function is used to set the ResumeDispatchProc that will be used
  1315.         by OSAExecuteEvent and OSADoEvent if either no event handler can be
  1316.         found in the context, or the context event hander "continues" control
  1317.         onward. The two constants kOSAUseStandardDispatch and kOSANoDispatch
  1318.         may also be passed to this routine indicating that the handler registered
  1319.         in the application with AEInstallEventHandler should be used, or no
  1320.         dispatch should occur, respectively.
  1321.     
  1322.         Errors:
  1323.             badComponentInstance    invalid scripting component instance
  1324.             errOSASystemError
  1325.     }
  1326.  
  1327. CONST
  1328.     kOSAUseStandardDispatch        = $FFFFFFFF;
  1329.  
  1330. {
  1331.         Special ResumeDispatchProc constant which may be passed to 
  1332.         OSASetResumeDispatchProc indicating that the handler registered
  1333.         in the application with AEInstallEventHandler should be used.
  1334.         
  1335.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1336.                 doesn't allow pointer types to be assigned to an enum.  All
  1337.                 constants must be assigned as enums to translate properly to
  1338.                 Pascal.
  1339.     }
  1340.     kOSANoDispatch                = 0;
  1341.  
  1342. {
  1343.         Special ResumeDispatchProc constant which may be passed to 
  1344.         OSASetResumeDispatchProc indicating that no dispatch should occur.
  1345.         
  1346.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1347.                 doesn't allow pointer types to be assigned to an enum.  All
  1348.                 constants must be assigned as enums to translate properly to
  1349.                 Pascal.
  1350.     }
  1351.     kOSADontUsePhac                = $0001;
  1352.  
  1353. {
  1354.         Special refCon constant that may be given to OSASetResumeDispatchProc
  1355.         only when kOSAUseStandardDispatch is used as the ResumeDispatchProc.
  1356.         This causes the standard dispatch to be performed, except the phac
  1357.         handler is not called.  This is useful during tinkerability, when
  1358.         the phac handler is used to lookup a context associated with an event's 
  1359.         direct parameter, and call OSAExecuteEvent or OSADoEvent.  Failure to
  1360.         bypass the phac handler would result in an infinite loop.
  1361.     }
  1362. FUNCTION OSAGetResumeDispatchProc(scriptingComponent: ComponentInstance; VAR resumeDispatchProc: AEEventHandlerUPP; VAR refCon: LONGINT): OSAError;
  1363.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1364.     INLINE $2F3C, $0008, $0802, $7000, $A82A;
  1365.     {$ENDC}
  1366. {
  1367.         OSAComponentFunctionInline(kOSASelectGetResumeDispatchProc, 8);
  1368.         Returns the registered ResumeDispatchProc.  If no ResumeDispatchProc has
  1369.         been registered, then kOSAUseStandardDispatch (the default) is returned.
  1370.     
  1371.         Errors:
  1372.             badComponentInstance    invalid scripting component instance
  1373.             errOSASystemError
  1374.     }
  1375. FUNCTION OSAExecuteEvent(scriptingComponent: ComponentInstance; {CONST}VAR theAppleEvent: AppleEvent; contextID: OSAID; modeFlags: LONGINT; VAR resultingScriptValueID: OSAID): OSAError;
  1376.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1377.     INLINE $2F3C, $0010, $0803, $7000, $A82A;
  1378.     {$ENDC}
  1379. {
  1380.         OSAComponentFunctionInline(kOSASelectExecuteEvent, 16);
  1381.         This call is similar to OSAExecute except the initial command to
  1382.         execute comes in the form of an AppleEvent.  If the contextID
  1383.         defines any event handlers for that event, they are used to process
  1384.         the event.  If no event handler can be found in the context
  1385.         errAEEventNotHandled is returned.  If an event handler is found and
  1386.         the hander "continues" control onward, the ResumeDispatchProc
  1387.         (registered with OSASetResumeDispatchProc, above) is called given the
  1388.         AppleEvent.  The result is returned as a scriptValueID.
  1389.     
  1390.         Errors:
  1391.             badComponentInstance    invalid scripting component instance
  1392.             errOSASystemError
  1393.             errOSAInvalidID
  1394.             errOSAScriptError:        the executing script got an error
  1395.             errAEEventNotHandled:    no handler for event in contextID
  1396.     
  1397.         ModeFlags:
  1398.             kOSAModeNeverInteract
  1399.             kOSAModeCanInteract
  1400.             kOSAModeAlwaysInteract
  1401.             kOSAModeCantSwitchLayer
  1402.             kOSAModeDontReconnect
  1403.             kOSAModeDoRecord
  1404.     }
  1405. FUNCTION OSADoEvent(scriptingComponent: ComponentInstance; {CONST}VAR theAppleEvent: AppleEvent; contextID: OSAID; modeFlags: LONGINT; VAR reply: AppleEvent): OSAError;
  1406.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1407.     INLINE $2F3C, $0010, $0804, $7000, $A82A;
  1408.     {$ENDC}
  1409. {
  1410.         OSAComponentFunctionInline(kOSASelectDoEvent, 16);
  1411.         This call is similar to OSADoScript except the initial command to
  1412.         execute comes in the form of an AppleEvent, and the result is an 
  1413.         AppleEvent reply record.  If the contextID defines any event handlers
  1414.         for that event, they are used to process the event.  If no event handler
  1415.         can be found in the context errAEEventNotHandled is returned.  If an
  1416.         event handler is found and the hander "continues" control onward, the
  1417.         ResumeDispatchProc (registered with OSASetResumeDispatchProc, above) is
  1418.         called given the AppleEvent.  The result is returned in the form of an
  1419.         AppleEvent reply descriptor. If at any time the script gets an error, or
  1420.         if the ResumeDispatchProc returns a reply event indicating an error,
  1421.         then the OSADoEvent call itself returns an error reply (i.e. OSADoEvent
  1422.         should never return errOSAScriptError).  Any error result returned by
  1423.         the ResumeDispatchProc will be returned by OSADoEvent.
  1424.     
  1425.         Errors:
  1426.             badComponentInstance    invalid scripting component instance
  1427.             errOSASystemError
  1428.             errOSAInvalidID
  1429.             errAEEventNotHandled:    no handler for event in contextID
  1430.     
  1431.         ModeFlags:
  1432.             kOSAModeNeverInteract
  1433.             kOSAModeCanInteract
  1434.             kOSAModeAlwaysInteract
  1435.             kOSAModeCantSwitchLayer
  1436.             kOSAModeDontReconnect
  1437.             kOSAModeDoRecord
  1438.     }
  1439. FUNCTION OSAMakeContext(scriptingComponent: ComponentInstance; {CONST}VAR contextName: AEDesc; parentContext: OSAID; VAR resultingContextID: OSAID): OSAError;
  1440.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  1441.     INLINE $2F3C, $000C, $0805, $7000, $A82A;
  1442.     {$ENDC}
  1443. {
  1444.         OSAComponentFunctionInline(kOSASelectMakeContext, 12);
  1445.         Makes a new empty context which may be passed to OSAExecute or 
  1446.         OSAExecuteEvent.  If contextName is typeNull, an unnamed context is
  1447.         created. If parentContext is kOSANullScript then the resulting context
  1448.         does not inherit bindings from any other context.
  1449.     
  1450.         Errors:
  1451.             badComponentInstance    invalid scripting component instance
  1452.             errOSASystemError
  1453.             errOSAInvalidID
  1454.             errAECoercionFail:        contextName is invalid
  1455.     }
  1456.  
  1457. {$ALIGN RESET}
  1458. {$POP}
  1459.  
  1460. {$SETC UsingIncludes := OSAIncludes}
  1461.  
  1462. {$ENDC} {__OSA__}
  1463.  
  1464. {$IFC NOT UsingIncludes}
  1465.  END.
  1466. {$ENDC}
  1467.